<!DOCTYPE html>

<html>

<!-- Mirrored from /theme/hplus/form_basic.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:15 GMT -->

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>乡土味士-后台管理中心 - 编辑图片</title>
<meta name="keywords" content="编辑图片">
<meta name="description" content="编辑图片">
<link rel="shortcut icon" href="favicon.ico">
<link href="__PUBLIC__/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
<link href="__PUBLIC__/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
<link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="__PUBLIC__/css/animate.min.css" rel="stylesheet">
<link href="__PUBLIC__/css/style.min862f.css?v=4.1.0" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="row">
    <div class="col-sm-12">
      <div class="ibox float-e-margins">
        <div class="ibox-content">
          <form class="form-horizontal" enctype="multipart/form-data" id="jvForm">
            <div class="hr-line-dashed"></div>
            <div class="form-group">
              <label class="col-sm-2 control-label">图片比例</label>
              <div class="col-sm-6">
                <!--<input class="form-control" type="text" id="picPro" name="proportion">-->
                <select class="form-control" id="picPro" name="proportion">
                <option value="1:1">1:1</option>
                <option value="3:2">3:2</option> 
                </select>
              </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
              <label class="col-sm-2 control-label">图片</label>
              <div class="col-sm-6">
                <input type="file" id="picinput" class="form-control"required>
                
                <!--图片路径--> 
                
                <img id="picShow" src="" style="width: 30%;margin-top: 20px;"> </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
              <div class="col-sm-4 col-sm-offset-2">
                <button class="btn btn-primary" type="submit">3秒后自动跳转</button>
                <span class="btn btn-primary" onClick="window.location.href='__MODULE__/Pic/'">返回</span>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<script src="__PUBLIC__/js/jquery.min.js?v=2.1.4"></script> 
<script src="__PUBLIC__/js/bootstrap.min.js?v=3.3.6"></script> 
<script src="__PUBLIC__/js/content.min.js?v=1.0.0"></script> 
<script src="__PUBLIC__/js/plugins/iCheck/icheck.min.js"></script> 
<script src="__PUBLIC__/js/jquery.form.js"></script> 
<script src="__PUBLIC__/js/layer/layer.js"></script> 
<script>

    $("#picinput").change(function () {

        var formData = new FormData();

        var picinput = document.getElementById("picinput");

        var domain = 'http://www.xiangtws.com';

        var proportion = $("#picPro").val();  //图片比例

        formData.append('pic', picinput.files[0]);       //将图片信息追加到formdata中

        formData.append('proportion', proportion);       //将图片比例追加到formdata中

        formData.append('domain', domain);       //将图片信息追加到formdata中

        $.ajax({

            url:'http://imgs.xiangtws.com/Api/Index/addPic',

            type:'POST',

            data:formData,                    // 上传formdata封装的数据

            dataType:'JSON',

            cache:false,                      // 不缓存

            processData:false,                // jQuery不要去处理发送的数据

            contentType:false,                // jQuery不要去设置Content-Type请求头

            success:function (data) {           //成功回调

                $("#picShow").attr("src",data.url);

                $("#picShow").show();

                window.setTimeout("location.href='http://www.xiangtws.com/XtwsBack/Pic/index'", 2000);

            },

            error: function (data,XMLHttpRequest, textStatus, errorThrown) {

                console.log('error');

            }

        });



    })







    //表单提交

    $(".js_form").ajaxForm({

        //定义返回JSON数据，还包括xml和script格式

        dataType: 'json',

        success: function(data) {

            //提交成功后调用

            if(data.status==1) {

                layer.msg(data.info, {icon:1,time:1000},

                    function(){

                        window.location.href= data.url;

                    });

            }else{

                layer.msg(data.info, {icon:2,time:1000});

            }

        }

    });

</script>
</body>

<!-- Mirrored from /theme/hplus/form_basic.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:15 GMT -->

</html>
